package gaileenchess;

import java.util.LinkedList;

public class Rook extends Piece
{
    public Rook(Common.Side s, int r, int c)
    {
        super(s, Type.ROOK, r, c);
    }
    
    public boolean isValidMove(Common.Side playerSide, Board board, Board.Position pos1, Board.Position pos2)
    {
        Board.Position diff = pos1.diff(pos2);
        
        if(Math.abs(diff.row)!=0&&Math.abs(diff.column)!=0)
        {
            return false;
        }
        
        return (!board.isPathBlocked(pos1, pos2));
    }
    
    public void getValidMoves(Common.Side playerSide, Board board, LinkedList<Board.Position.Move> pieces, boolean check, int player)
    {
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(1, 0), 0, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(0, 1), 0, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(-1, 0), 0, check, player);
        getValidMovesHelper(playerSide, board, pieces, new Board.Position(0, -1), 0, check, player);
    }
}
